# Search File and Move

Searches for files in a source location using SharePoint search and moves matching files to a target location, preserving the folder hierarchy.

Filename pattern: filename must contain both searchfile AND move (case-insensitive).
Example: 20240115 searchfileandmove archive.xlsx

# Columns

Name Required Description
SourceFolder / SourceFolderUrl / SourceDirectory Yes Server-relative URL of the source document library or folder.
SourceFolderSearch / SourceDirectorySearch No SharePoint search query to filter files within the source folder (e.g. LastModifiedTime<2010-01-01). When omitted, all files are matched.
TargetFolder / TargetFolderUrl / TargetDirectory Yes Server-relative URL of the target document library or folder.
RemoveEmptyFolder / RemoveEmptyFolders / RemoveEmptyDirectory No Boolean. When true, source folders that become empty after moving are removed (deepest first). Default: false.

Both SourceFolder and TargetFolder are required.

# Behavior

The handler uses SharePoint search (FindFilesViaSearchExecute) to locate matching files in the source folder. Each file is moved to the target, recreating the relative folder path under the target root. Target subfolders are created automatically, copying folder properties from the source.

The search runs twice with a 30-second pause between runs to account for search indexer delays.

When RemoveEmptyFolder is true, source folders that contain no remaining files after the move are removed, starting with the deepest paths first. Folders that are not empty are silently skipped.

Last Updated: 4/20/2026, 12:54:05 PM